package jsyf.oa.dao.system;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import jsyf.oa.entity.system.ShouldSignInEntity;
import jsyf.oa.entity.system.TargetEntity;
import jsyf.oa.idao.BaseDao;
import jsyf.oa.ientity.IBaseEntity;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;

/**
 * Created by WHH-PC on 2018/2/5.
 */
@Repository
public class ShouldSignInDao extends BaseDao {
    public ShouldSignInDao() {
        super.iBaseEntity = new ShouldSignInEntity();
    }

    @Override
    public IBaseEntity convertJson2Entity(JSONObject json) {
        return JSON.toJavaObject(json, ShouldSignInEntity.class);
    }


    public void insertBatch(List<ShouldSignInEntity> shouldSignInList){
        List<LinkedHashMap<String,Object>> insertList = new ArrayList();
        LinkedHashMap<String,Object> shouldSignInMap = null;
        for (int i = 0; i < shouldSignInList.size(); i++) {
            ShouldSignInEntity shouldSignInEntity = shouldSignInList.get(i);
            shouldSignInMap = new LinkedHashMap<>();
            shouldSignInMap.put("ID",super.generateKey());
            shouldSignInMap.put("ROLE_ID",shouldSignInEntity.getRoleId());
            shouldSignInMap.put("SHOULD_MONTH",shouldSignInEntity.getShouldMonth());
            shouldSignInMap.put("SHOULD_SIGNIN",shouldSignInEntity.getShouldSignIn());
            shouldSignInMap.put("CREATE_USER_ID",shouldSignInEntity.getCreateUserId());
            shouldSignInMap.put("FRONT_FLAG",shouldSignInEntity.getFrontFlag());
            shouldSignInMap.put("CREATE_TIME",this.getCurrentTime());
            insertList.add(shouldSignInMap);
        }
        super.insertBatch("T_SYS_SHOULD_SIGN_IN", insertList);
    }
}

